What is @commitlint/lint?
The @commitlint/lint package is a part of the commitlint toolset that is used to lint commit messages according to a specified set of rules. It helps maintain a consistent commit history and enforces a commit message convention, which is beneficial for automated processing of commit logs, generating changelogs, and aiding in code reviews.
Linting Commit Messages
This feature allows you to lint commit messages using a set of predefined rules. The code sample demonstrates how to use the lint function to check if a commit message follows the specified rules for the commit type and subject case.
const { lint } = require('@commitlint/lint');
const message = 'feat: add new feature';
const rules = {
'type-enum': [2, 'always', ['feat', 'fix', 'docs', 'style', 'refactor', 'test', 'chore']],
'subject-case': [2, 'never', ['start-case', 'pascal-case', 'upper-case']]
};
lint(message, rules).then(report => {
console.log(report);
});